package library.net.retrofit.callback;

/**
 * progress listener(for download)
 * T: result(response) type
 *
 * @author Created by qiang.hou on 2017/12/6.
 * @version 1.0
 */
public interface IRxCallback<T> {

    /**
     * on start
     *
     * @param tag tag
     */
    void onStart(Object tag);

    /**
     * on pause
     *
     * @param tag tag
     * @param t   result(response)
     */
    void onPause(Object tag, T t);

    /**
     * on progress(for download)
     *
     * @param tag         tag
     * @param speed       download speed
     * @param readLength  already download length
     * @param totalLength total size of download file
     */
    void onProgress(Object tag, long speed, long readLength, long totalLength);

    /**
     * on success
     *
     * @param tag tag
     * @param t   result(response)
     */
    void onSuccess(Object tag, T t);

    /**
     * on success
     *
     * @param tag    tag
     * @param t      result(response)
     * @param method http method
     */
    void onSuccess(Object tag, T t, String method);

    /**
     * on success(for download)
     *
     * @param tag      tag
     * @param path     local path
     * @param name     local file name
     * @param fileSize size of download file
     */
    void onSuccess(Object tag, String path, String name, long fileSize);


    /**
     * on complete
     *
     * @param tag tag
     */
    void onCompleted(Object tag);

    /**
     * on complete
     *
     * @param tag tag
     * @param t   result(response)
     */
    void onCompleted(Object tag, T t);

    /**
     * on error
     *
     * @param tag tag
     * @param e   throwable
     */
    void onError(Object tag, Throwable e);

    /**
     * on cancel
     *
     * @param tag tag
     * @param t   result(response)
     */
    void onCancel(Object tag, T t);
}
